package com.ykdl.member.kid.adapters;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.Resources.Theme;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsoluteLayout.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.TextView;

public class AskDoctorTagAdapter extends BaseAdapter {

	private Context mContext;
	private List<String> mList;
	private int mSelectedTab;
	public AskDoctorTagAdapter(Context context) {
		mContext = context;
		/* attrs.xml <declare-styleable> */
		Theme theme = mContext.getTheme();
	}
	public void setlist(List<String> list) {
		this.mList = list ;
	}

	public void setSelectedTab(int tab) {
		if (tab != mSelectedTab) {
			mSelectedTab = tab;
			notifyDataSetChanged();
		}
	}

	public int getSelectedTab() {
		return mSelectedTab;
	}

	public int getCount() {
		if (mList!=null) {
			return mList.size();
		}else {
			return 0;
			
		}
	}

	public Object getItem(int position) {
		return mList.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {

		TextView text = null;
		if (convertView == null) {
			text = new TextView(mContext);
		} else {
			text = (TextView) convertView;
		}
		text.setTextColor(0xff603805);
		
		text.setText(mList.get(position));
		android.widget.Gallery.LayoutParams params =new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, 50);
		text.setLayoutParams(params);
		text.setGravity(Gravity.CENTER);
		text.setPadding(20, 0, 20, 0);
		if (position == mSelectedTab) {
			text.setBackgroundColor(0xffFFA500);
		} else {
			text.setBackgroundColor(0xffFFffff);
		}
		return text;
	}

}
